﻿using DXBase.D3D;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace DXBase.Structs
{
	/// <summary>
	/// Represent the Vertex loaded by DXBase.Loader
	/// </summary>
	[StructLayout(LayoutKind.Sequential)]
	public struct ModelVertex
	{
		public Vector3F Position;
		public Vector3F Normal;
		public Color4B ColorDiffuse;
		public Vector3F Tangent;
		public Vector3F Bitangent;
		public Vector2F TextureUV;
		public Vector2F TextureUV2;
		public SByte4 BoneIndices;
		public SByte4 BoneWeights; // last Weight not used, calculated inside the vertex shader

		public static VertexLayout GetLayout()
		{
			var result = new VertexLayout();
			result.Add("POSITION", Format.R32G32B32_float, 0);
			result.Add("NORMAL", Format.R32G32B32_float, 0);
			result.Add("COLOR", Format.B8g8r8a8_unorm, 0);
			result.Add("TANGENT", Format.R32G32B32_float, 0);
			result.Add("TANGENT", Format.R32G32B32_float, 0);
			result.Add("TEXCOORD", Format.R32g32_float, 0);
			result.Add("TEXCOORD", Format.R32g32_float, 0);
			result.Add("BLENDINDICES", Format.R8g8b8a8_sint, 0);
			result.Add("BLENDWEIGHT", Format.R8g8b8a8_sint, 0);
			throw new NotImplementedException("TODO check semantic names (bitangent? bone?) and bone format");
			return result;
		}
	}
}
